package client;

import model.Book;
import serviceDefine.BookService;


import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.List;

public class Client {
    public static void main(String[] args) {
      try {
          String name = "BookManager";
          String serverIP = "192.168.232.140";
          int serverPort = 1099;
          Registry registry = LocateRegistry.getRegistry(serverIP,serverPort);
          BookService bookService = (BookService)registry.lookup(name);
          bookService.delete(1);
          Book book = new Book("world","biao",74.33);
          bookService.add(book);
          Book book1 = bookService.queryById(2);
          System.out.println(book1);
          List<Book> bookList = bookService.queryByName("world");
          for(Book b:bookList){
              System.out.println(b);
          }
      }catch (Exception e){
          e.printStackTrace();
      }
    }
}
